import Vue from 'vue'
import Router from 'vue-router'
import store from '../store/store.js'
import page from './page'

Vue.use(Router)

const router = new Router({routes:page})
// 每个页面都强制验证是否授权登录
router.beforeEach((to, from, next) => {
  if(to.path == '/login' || to.path == '/register' || to.path == '/forgetPWD') {
    next()
    return
  }
  if (!store.state.login && to.path !== '/login') {
    next('/login')
    return
  }
  next()
})
export default router

